
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.FeedTaskQuality;
import cn.edu.scau.cmi.hombio.domain.PigType;
import cn.edu.scau.cmi.hombio.domain.Pigsty;
import cn.edu.scau.cmi.hombio.domain.Task;
import cn.edu.scau.cmi.hombio.domain.TaskPigsty;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class TaskPigstyServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TaskPigstyService service;

	/**
	 * Instantiates a new TaskPigstyServiceTest.
	 *
	 */
	public TaskPigstyServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Load an existing TaskPigsty entity
	* 
	 */
	@Test
	public void loadTaskPigstys() {
		Set<TaskPigsty> response = null;
		response = service.loadTaskPigstys();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTaskPigstys
	}

	/**
	 * Operation Unit Test
	* Return all TaskPigsty entity
	* 
	 */
	@Test
	public void findAllTaskPigstys() {
		// TODO: JUnit - Populate test inputs for operation: findAllTaskPigstys 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<TaskPigsty> response = null;
		response = service.findAllTaskPigstys(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTaskPigstys
	}

	/**
	 * Operation Unit Test
	* Delete an existing FeedTaskQuality entity
	* 
	 */
	@Test
	public void deleteTaskPigstyFeedTaskQualities() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskPigstyFeedTaskQualities 
		Integer taskpigsty_id = 0;
		Integer related_feedtaskqualities_id = 0;
		TaskPigsty response = null;
		response = service.deleteTaskPigstyFeedTaskQualities(taskpigsty_id, related_feedtaskqualities_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskPigstyFeedTaskQualities
	}

	/**
	 * Operation Unit Test
	* Delete an existing TaskPigsty entity
	* 
	 */
	@Test
	public void deleteTaskPigsty() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskPigsty 
		TaskPigsty taskpigsty = new cn.edu.scau.cmi.hombio.domain.TaskPigsty();
		service.deleteTaskPigsty(taskpigsty);
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveTaskPigstyTask() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskPigstyTask 
		Integer id = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		TaskPigsty response = null;
		response = service.saveTaskPigstyTask(id, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskPigstyTask
	}

	/**
	 * Operation Unit Test
	* Save an existing TaskPigsty entity
	* 
	 */
	@Test
	public void saveTaskPigsty() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskPigsty 
		TaskPigsty taskpigsty_1 = new cn.edu.scau.cmi.hombio.domain.TaskPigsty();
		service.saveTaskPigsty(taskpigsty_1);
	}

	/**
	 * Operation Unit Test
	* Return a count of all TaskPigsty entity
	* 
	 */
	@Test
	public void countTaskPigstys() {
		Integer response = null;
		response = service.countTaskPigstys();
		// TODO: JUnit - Add assertions to test outputs of operation: countTaskPigstys
	}

	/**
	 * Operation Unit Test
	* Delete an existing Pigsty entity
	* 
	 */
	@Test
	public void deleteTaskPigstyPigsty() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskPigstyPigsty 
		Integer taskpigsty_id_1 = 0;
		Integer related_pigsty_id = 0;
		TaskPigsty response = null;
		response = service.deleteTaskPigstyPigsty(taskpigsty_id_1, related_pigsty_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskPigstyPigsty
	}

	/**
	 * Operation Unit Test
	* Save an existing Pigsty entity
	* 
	 */
	@Test
	public void saveTaskPigstyPigsty() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskPigstyPigsty 
		Integer id_1 = 0;
		Pigsty related_pigsty = new cn.edu.scau.cmi.hombio.domain.Pigsty();
		TaskPigsty response = null;
		response = service.saveTaskPigstyPigsty(id_1, related_pigsty);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskPigstyPigsty
	}

	/**
	 * Operation Unit Test
	* Save an existing FeedTaskQuality entity
	* 
	 */
	@Test
	public void saveTaskPigstyFeedTaskQualities() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskPigstyFeedTaskQualities 
		Integer id_2 = 0;
		FeedTaskQuality related_feedtaskqualities = new cn.edu.scau.cmi.hombio.domain.FeedTaskQuality();
		TaskPigsty response = null;
		response = service.saveTaskPigstyFeedTaskQualities(id_2, related_feedtaskqualities);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskPigstyFeedTaskQualities
	}

	/**
	 * Operation Unit Test
	* Save an existing PigType entity
	* 
	 */
	@Test
	public void saveTaskPigstyPigType() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskPigstyPigType 
		Integer id_3 = 0;
		PigType related_pigtype = new cn.edu.scau.cmi.hombio.domain.PigType();
		TaskPigsty response = null;
		response = service.saveTaskPigstyPigType(id_3, related_pigtype);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskPigstyPigType
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTaskPigstyByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTaskPigstyByPrimaryKey 
		Integer id_4 = 0;
		TaskPigsty response = null;
		response = service.findTaskPigstyByPrimaryKey(id_4);
		// TODO: JUnit - Add assertions to test outputs of operation: findTaskPigstyByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing PigType entity
	* 
	 */
	@Test
	public void deleteTaskPigstyPigType() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskPigstyPigType 
		Integer taskpigsty_id_2 = 0;
		Integer related_pigtype_id = 0;
		TaskPigsty response = null;
		response = service.deleteTaskPigstyPigType(taskpigsty_id_2, related_pigtype_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskPigstyPigType
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteTaskPigstyTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskPigstyTask 
		Integer taskpigsty_id_3 = 0;
		Integer related_task_id = 0;
		TaskPigsty response = null;
		response = service.deleteTaskPigstyTask(taskpigsty_id_3, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskPigstyTask
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
